const path = require('path');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');

module.exports = require('webpack-merge').merge(require('./webpack.common'), {
  mode: 'development',
  devtool: 'inline-source-map',
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
      {
        // test: /module\.less$/,
        test: /\.less$/,
        use: [
          'style-loader',
          { loader: 'css-loader', options: { modules: { localIdentName: '[name]--[hash:base64:5]' } } },
          {
            loader: 'less-loader',
            options: {
              lessOptions: {
                javascriptEnabled: true,
              },
            },
          },
        ],
      },
      // {
      //   test: /\.less$/,
      //   exclude: [/\.module(s?)\.less$/],
      //   use: [
      //     'style-loader',
      //     'css-loader',
      //     {
      //       loader: 'less-loader',
      //       options: {
      //         lessOptions: {
      //           javascriptEnabled: true,
      //         },
      //       },
      //     },
      //   ],
      // },
    ],
  },

  devServer: {
    port: 4000,
    static: path.resolve(__dirname, '../dist'),
  },
  plugins: [
    new FriendlyErrorsPlugin({
      compilationSuccessInfo: {
        messages: [`Your application is running here: http://localhost:4000`],
      },
      onErrors: undefined,
    }),
  ],
});
